package com.egao.orderB.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.*;
import com.egao.common.core.annotation.OperLog;
import com.egao.orderB.entity.PutGoods;
import com.egao.orderB.entity.PutInfo;
import com.egao.orderB.entity.PutStorage;
import com.egao.orderB.entity.PutStorageAndInfo;
import com.egao.orderB.service.PutStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.ui.Model;


/**
 *
 * 入库信息
 * @author : Doman
 * @date : 2021-12-23 15:43:48
 * @version ：1.0
 */

@Api(tags = "入库信息 主要的")
@RestController
@RequestMapping("/api/orderB/putStorage")
public class PutStorageController extends BaseController {

	@Autowired
	private PutStorageService putStorageService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation(value ="分页查询入库信息",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    "exStoraged: 是否出库 0未出库  1已出库\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "exStoraged: 是否出库 0未出库  1已出库\n" +
    "orderNum:排序\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list")
  public JsonResult page(PageResult2<T> page, PutStorage putStorage) throws Exception{
    return putStorageService.list(page, putStorage, getLoginUser());
  }

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation(value ="分页查询 入库信息,入库单基本信息  合并一起的结果",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    "date1:开始时间\n" +
    "date2:结束时间\n" +
    "customer:客户\n" +
      "exStoraged: 是否出库 0未出库  1已出库\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "exStoraged: 是否出库 0未出库  1已出库\n" +


    "putInfoId:入库信息id\n" +
    "insideRemark:内部备注\n" +
    "entrustmentRemark:托书备注\n" +
    "name:业务员id\n" +
    "stockNum:业务员\n" +
    "salesmanId:业务员Id\n" +
    "salesman:业务员\n" +
    "examineId:审核员Id\n" +
    "examine:审核员\n" +
    "customerServiceId:客服id\n" +
    "customerService:客服\n" +
    "overseaCustomerService:海外客服\n" +
    "operaterId:操作Id\n" +
    "operater:操作\n" +
    "fileName:文件\n" +
    "financialAffairs:财务\n" +
    "bookingSpace:订舱/仓管\n" +
    "cabinetNum:派车/柜号\n" +
    "billOfLading:订单号\n" +
    "customerId:客户id\n" +
    "customer:客户\n" +
    "bookingAgent:订舱代理\n" +
    "dispatchAgent:派送代理\n" +
    "customsClearanceAgent:清关代理\n" +
    "productCode:货物品名 / 商品编码\n" +
    "productNum:商品数量\n" +
    "tradeTerms:贸易条款 / 申报货值\n" +
    "reconciliationDate:对账日期\n" +
    "bookingSpaceEtd:订舱ETD\n" +
    "dispatchDate:派送日期\n" +
    "paymentPath:付款方式\n" +
    "termsOfService:服务条款\n" +
    "referenceNumberEdi:参考号(EDI)\n" +
    "ctnMawb:CTN/MAWB#\n" +
    "originatingArea:始发区域\n" +
    "arrivalArea:到达区域\n" +
    "placeOfReceipt:收货地\n" +
    "originSz:始发地 (SZ001)\n" +
    "transitPlace:中转地\n" +
    "destination:目的地\n" +
    "hbl:HBL号\n" +
    "consigneeId:收货人id\n" +
    "consignee:收货人\n" +
    "notifierId:通知人id\n" +
    "notifier:通知人\n" +
    "pickUpAgent:提货代理\n" +
    "shippingMark:唛 头\n" +
    "productDec:货物描述\n" +
    "shippingAddress:送货地址\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list13")
  public JsonResult page13(PageResult2<T> page, PutStorageAndInfo putStorageAndInfo) throws Exception{
    return putStorageService.list13(page, putStorageAndInfo, getLoginUser());
  }

  /**
   * 查询全部入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation("查询全部入库信息")
  @PostMapping("/listAll")
  public JsonResult list(PutStorage putStorage){
    return putStorageService.list(putStorage, getLoginUser());
  }

  /**
   * 查询全部入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation(value ="首页入库量",notes = "" +
          "productName:类型\n" +
          "num:数量\n" +
          "")
  @PostMapping("/listVolume")
  public JsonResult listVolume(PutStorage putStorage){
    return putStorageService.listVolume(putStorage, getLoginUser());
  }

  /**
   * 查询全部入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation(value ="首页按月入库订单数",notes = "" +
          "date1:开始月份2022-01\n" +
          "date2:结束月份2022-03\n" +
          "keywords:具体到某一个月 2022-03  \n" +
          "")
  @PostMapping("/listMonth")
  public JsonResult listMonth(PutStorage putStorage){
    return putStorageService.listMonth(putStorage, getLoginUser());
  }

  /**
   * 根据id查询入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation("根据id查询入库信息")
  @PostMapping("/get")
  public JsonResult get(PutStorage putStorage) {
    return putStorageService.getById(putStorage);
  }

  /**
   * 根据id查询入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:list')")
  @ApiOperation("根据id查询入库信息")
  @PostMapping("/get13")
  public JsonResult get13(PutStorageAndInfo putStorageAndInfo) {
    return putStorageService.get13(putStorageAndInfo);
  }


  /**
   * 添加入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:save')")
  @OperLog(value = "入库单,入库单基本信息,入库商品详情 三个一起保存 ", desc = "添加", param = false, result = true)
  @ApiOperation(value ="入库单,入库单基本信息,入库商品详情 三个一起保存 ",notes = "" +
    "putStorage:{\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "}\n\n\n" +
    "putGoods:[{\n" +
          "shippingMark:箱唛\n" +
          "sku:SKU\n" +
          "name:货名\n" +
          "stockNum:库存\n" +
          "remark:备注\n" +
          "num:件数\n" +
          "pack:包装\n" +
          "weight:重量\n" +
          "totalWeight:总重量\n" +
          "length:长\n" +
          "width:宽\n" +
          "high:高\n" +
          "volume:体积\n" +
          "totalVolume:总体积\n" +
          "palletNum:托盘数\n" +
          "orderNum:排序\n" +
    "}]\n\n\n" +
    "putInfo:{\n" +
          "insideRemark:内部备注\n" +
          "entrustmentRemark:托书备注\n" +
          "name:业务员id\n" +
          "stockNum:业务员\n" +
          "salesmanId:业务员Id\n" +
          "salesman:业务员\n" +
          "examineId:审核员Id\n" +
          "examine:审核员\n" +
          "customerServiceId:客服id\n" +
          "customerService:客服\n" +
          "overseaCustomerService:海外客服\n" +
          "operaterId:操作Id\n" +
          "operater:操作\n" +
          "fileName:文件\n" +
          "financialAffairs:财务\n" +
          "bookingSpace:订舱/仓管\n" +
          "cabinetNum:派车/柜号\n" +
          "billOfLading:订单号\n" +
          "customerId:客户id\n" +
          "customer:客户\n" +
          "bookingAgent:订舱代理\n" +
          "dispatchAgent:派送代理\n" +
          "customsClearanceAgent:清关代理\n" +
          "productCode:货物品名 / 商品编码\n" +
          "productNum:商品数量\n" +
          "tradeTerms:贸易条款 / 申报货值\n" +
          "reconciliationDate:对账日期\n" +
          "bookingSpaceEtd:订舱ETD\n" +
          "dispatchDate:派送日期\n" +
          "paymentPath:付款方式\n" +
          "termsOfService:服务条款\n" +
          "referenceNumberEdi:参考号(EDI)\n" +
          "ctnMawb:CTN/MAWB#\n" +
          "originatingArea:始发区域\n" +
          "arrivalArea:到达区域\n" +
          "placeOfReceipt:收货地\n" +
          "originSz:始发地 (SZ001)\n" +
          "transitPlace:中转地\n" +
          "destination:目的地\n" +
          "hbl:HBL号\n" +
          "consigneeId:收货人id\n" +
          "consignee:收货人\n" +
          "notifierId:通知人id\n" +
          "notifier:通知人\n" +
          "pickUpAgent:提货代理\n" +
          "shippingMark:唛 头\n" +
          "productDec:货物描述\n" +
          "shippingAddress:送货地址\n" +
          "remark:备注\n" +
          "orderNum:排序\n" +
    "}\n\n\n" +
    "",httpMethod = "POST")
  @PostMapping("/saveStorage")
  public JsonResult saveStorage(Model model, String putStorage, String putGoodsList, String putInfo) {
    return putStorageService.saveStorage(putStorage, putGoodsList, putInfo, getLoginUser());
  }

  /**
   * 添加入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:save')")
  @OperLog(value = "入库单,入库单基本信息,入库商品详情 三个一起保存 ", desc = "添加", param = false, result = true)
  @ApiOperation(value ="入库单,入库单基本信息,入库商品详情 三个一起保存 ",notes = "" +
    "putStorage:{\n" +
    "id:id\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "}\n\n\n" +

    "putInfo:{\n" +
          "id:id\n" +
          "insideRemark:内部备注\n" +
          "entrustmentRemark:托书备注\n" +
          "name:业务员id\n" +
          "stockNum:业务员\n" +
          "salesmanId:业务员Id\n" +
          "salesman:业务员\n" +
          "examineId:审核员Id\n" +
          "examine:审核员\n" +
          "customerServiceId:客服id\n" +
          "customerService:客服\n" +
          "overseaCustomerService:海外客服\n" +
          "operaterId:操作Id\n" +
          "operater:操作\n" +
          "fileName:文件\n" +
          "financialAffairs:财务\n" +
          "bookingSpace:订舱/仓管\n" +
          "cabinetNum:派车/柜号\n" +
          "billOfLading:订单号\n" +
          "customerId:客户id\n" +
          "customer:客户\n" +
          "bookingAgent:订舱代理\n" +
          "dispatchAgent:派送代理\n" +
          "customsClearanceAgent:清关代理\n" +
          "productCode:货物品名 / 商品编码\n" +
          "productNum:商品数量\n" +
          "tradeTerms:贸易条款 / 申报货值\n" +
          "reconciliationDate:对账日期\n" +
          "bookingSpaceEtd:订舱ETD\n" +
          "dispatchDate:派送日期\n" +
          "paymentPath:付款方式\n" +
          "termsOfService:服务条款\n" +
          "referenceNumberEdi:参考号(EDI)\n" +
          "ctnMawb:CTN/MAWB#\n" +
          "originatingArea:始发区域\n" +
          "arrivalArea:到达区域\n" +
          "placeOfReceipt:收货地\n" +
          "originSz:始发地 (SZ001)\n" +
          "transitPlace:中转地\n" +
          "destination:目的地\n" +
          "hbl:HBL号\n" +
          "consigneeId:收货人id\n" +
          "consignee:收货人\n" +
          "notifierId:通知人id\n" +
          "notifier:通知人\n" +
          "pickUpAgent:提货代理\n" +
          "shippingMark:唛 头\n" +
          "productDec:货物描述\n" +
          "shippingAddress:送货地址\n" +
          "remark:备注\n" +
          "orderNum:排序\n" +
    "}\n\n\n" +
    "",httpMethod = "POST")
  @PostMapping("/updateStorage13")
  public JsonResult updateStorage13(Model model, String putStorage, String putInfo) {
    return putStorageService.updateStorage13(putStorage, putInfo, getLoginUser());
  }


  /**
   * 添加入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:save')")
  @OperLog(value = "入库信息", desc = "添加", param = false, result = true)
  @ApiOperation(value ="添加入库信息",notes = "" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "",httpMethod = "POST")
  @PostMapping("/save")
  public JsonResult save(Model model, PutStorage putStorage) {
    return putStorageService.save(putStorage, getLoginUser());
  }

  /**
   * 修改入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:update')")
  @OperLog(value = "入库信息", desc = "修改", param = false, result = true)
  @ApiOperation(value ="修改入库信息",notes = "" +
    "id:id\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "",httpMethod = "POST")
  @PostMapping("/update")
  public JsonResult update(Model model, PutStorage putStorage) {
    return putStorageService.update(putStorage, getLoginUser());
  }

  /**
   * 删除入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:remove')")
  @OperLog(value = "入库信息", desc = "删除", result = true)
  @ApiOperation(value ="删除入库信息",notes = "" +
    "id:id\n" +
    "",httpMethod = "POST")
  @PostMapping("/remove")
  public JsonResult remove(PutStorage putStorage ) {
    return putStorageService.remove(putStorage, getLoginUser());
  }

}
